package com.bb.util;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class GetSqlSessionUtil {
	public SqlSession getSqlSession(){
		InputStream in = null;
		SqlSession se = null;
		try {
			/*读取配置文件*/
			in = Resources.getResourceAsStream("config/sqlConfigMap.xml");
			/*创建sqlSessionFactory工厂*/
			SqlSessionFactory build = new SqlSessionFactoryBuilder().build(in);
			//获得SqlSession
			se = build.openSession();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return se;
	}
}
